package com.example.homework1;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import Adapter.Myadapter;

public class MainActivity extends AppCompatActivity {

   private List<Message> MessageList = new ArrayList<>();
    private void initFruit() {
        for (int i = 0; i < 5; ++i) {
            Message apple = new Message("抖音小助手", 1,"#请收下我的双下巴祝福","昨天");
            MessageList.add(apple);
            Message banana = new Message("游戏小助手", 1,"抖出好游戏","刚刚");
            MessageList.add(banana);
            Message orange = new Message("系统消息", 1,"账号登录提醒","12:28");
            MessageList.add(orange);
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ActionBar acbar = getSupportActionBar();
        if(acbar!=null){
            acbar.hide();
        }
        initFruit();

        ImageButton button = (ImageButton)findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"you click the button",Toast.LENGTH_SHORT).show();
            }
        });

        RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycle_view);
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
            recyclerView.setLayoutManager(linearLayoutManager);
            Myadapter myadapter = new Myadapter(MessageList);
            recyclerView.setAdapter(myadapter);

    }
}